# -*- coding: utf-8 -*-
import scrapy
from bs4 import BeautifulSoup
from ..items import CityItem


class HotelSpider(scrapy.Spider):
    name = 'hotel'
    allowed_domains = ['bnb.qunar.com']
    start_urls = ['http://bnb.qunar.com/hotcity.jsp']

    def parse(self, response):
        pass
        html = response.text
        soup = BeautifulSoup(html, "html")
        cityList = soup.findAll("div", class_="e_city_list")
        itemList = []
        for cityFist in cityList:
            aList = cityFist.findAll("a")
            for a in aList:
                item = CityItem()
                item['cityName'] = a.text
                item['cityUrl'] = a.get("href")
                itemList.append(item)
        return itemList
